From: Florian Müllner Date: Sat, 11 Sep 2010 22:18:52 +0000 (+0200) Subject: st: Use template material for transitions X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~9756 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=862f1ea18ceee3e652c02303beee35a7c82120f5;p=gnome-shell.git st: Use template material for transitions To avoid compiling a new shader each time a transition is started, use a copy of a static template material. See http://bugzilla.clutter-project.org/show_bug.cgi?id=2280#c5. https://bugzilla.gnome.org/show_bug.cgi?id=629384 --- diff --git a/src/st/st-theme-node-transition.c b/src/st/st-theme-node-transition.c index 884f806ae..e523c5ce3 100644 --- a/src/st/st-theme-node-transition.c +++ b/src/st/st-theme-node-transition.c @@ -55,6 +55,9 @@ struct _StThemeNodeTransitionPrivate { static guint signals[LAST_SIGNAL] = { 0 }; +/* template material to avoid unnecessary shader compilation */ +static CoglHandle global_material = COGL_INVALID_HANDLE; + G_DEFINE_TYPE (StThemeNodeTransition, st_theme_node_transition, G_TYPE_OBJECT); @@ -244,21 +247,27 @@ setup_framebuffers (StThemeNodeTransition *transition, g_return_val_if_fail (priv->old_offscreen != COGL_INVALID_HANDLE, FALSE); g_return_val_if_fail (priv->new_offscreen != COGL_INVALID_HANDLE, FALSE); - if (priv->material) - cogl_handle_unref (priv->material); - priv->material = cogl_material_new (); - - cogl_material_set_layer_combine (priv->material, 0, - "RGBA = REPLACE (TEXTURE)", - NULL); - cogl_material_set_layer_combine (priv->material, 1, - "RGBA = INTERPOLATE (PREVIOUS, " - "TEXTURE, " - "CONSTANT[A])", - NULL); - cogl_material_set_layer_combine (priv->material, 2, - "RGBA = MODULATE (PREVIOUS, PRIMARY)", - NULL); + if (priv->material == NULL) + { + if (G_UNLIKELY (global_material == COGL_INVALID_HANDLE)) + { + global_material = cogl_material_new (); + + cogl_material_set_layer_combine (global_material, 0, + "RGBA = REPLACE (TEXTURE)", + NULL); + cogl_material_set_layer_combine (global_material, 1, + "RGBA = INTERPOLATE (PREVIOUS, " + "TEXTURE, " + "CONSTANT[A])", + NULL); + cogl_material_set_layer_combine (global_material, 2, + "RGBA = MODULATE (PREVIOUS, " + "PRIMARY)", + NULL); + } + priv->material = cogl_material_copy (global_material); + } cogl_material_set_layer (priv->material, 0, priv->new_texture); cogl_material_set_layer (priv->material, 1, priv->old_texture);